<?php


namespace App\Admin\Server;

use App\Models\Good;
use App\Models\GroupModel;
use Dcat\Admin\Grid;

class GroupService extends Grid\LazyRenderable
{
    public function grid():Grid
    {
        //用于渲染商品页面
        return Grid::make(new Good(),function (Grid $grid){
            $grid->column('id');
            $grid->column('goods_name');
            $grid->column('goods_price');
            $grid->switch ('goods_type');
            $grid->column('goods_amount');


            $grid->column('goods_image')->image();
            $grid->column('goods_item');
            $grid->column('goods_describe');
            $grid->column('goods_status')->display(function ($e){
                if($e==1){
                    return '上架';
                }elseif ($e==2){
                    return '下架';
                }
            });

            $grid->rowSelector()->titleColumn('goods_name');
            $grid->paginate(9);
            $grid->disableActions();
            $grid->filter(function (Grid\Filter $filter){
               $filter->like('goods_name')->width(4);
               $filter->like('name')->width(4);
            });
        });
    }
}